package com.aaa.dao;

import com.aaa.entity.Massage;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

public interface L_ZHSHDao {


    @Select("  <script>SELECT  a.manage,a.id,a.`name`,a.unituser,a.`password`,a.number,a.email,a.linkman,a.linknum,a.address,a.introduce,a.state,a.SHtime,a.SHuser, "
            + "  b.manage,c.type,d.nature,e.industry,f.grading  "
            + "  FROM regist a "
            + "  JOIN manage_unit b on a.manage=b.id"
            + "  JOIN unit_type c on a.type=c.id"
            + "  JOIN unit_nature d on a.nature=d.id"
            + "  JOIN industry e ON a.industry=e.id"
            + "  JOIN grading f on a.grading=f.id  where a.state=1   <if test=\"manage!=null and manage!=1\">and a.manage=#{manage}  or a.manage>#{manage} </if>    "
            + "  <if test=\"name!=null and name!=''\"> and name like concat('%',#{name},'%')</if>  "
            + "  limit #{start},#{pageSize}</script>")
    List<Map> getAll(Map map);

    @Select("  <script>SELECT  a.manage,a.id,a.`name`,a.unituser,a.`password`,a.number,a.email,a.linkman,a.linknum,a.address,a.introduce,a.state,a.SHtime,a.SHuser, "
            + "  b.manage,c.type,d.nature,e.industry,f.grading  "
            + "  FROM regist a  "
            + "  JOIN manage_unit b on a.manage=b.id"
            + "  JOIN unit_type c on a.type=c.id"
            + "  JOIN unit_nature d on a.nature=d.id"
            + "  JOIN industry e ON a.industry=e.id"
            + "  JOIN grading f on a.grading=f.id       "
            + "  <if test=\"name!=null and name!=''\"> and name like concat('%',#{name},'%')</if>  "
            + "  limit #{start},#{pageSize}</script>")
    List<Map> getAll1(Map map);



    @Select("<script>select count(id) from regist " +
            " where 1=1 <if test=\"id!=null and id!=0\"> and id =#{id}</if>" +
            " <if test=\"name!=null and name!=''\"> and name like concat('%',#{name},'%')</if></script>")
    Integer getCount(Map map);

    @Select(" SELECT  a.id,a.`name`,a.unituser,a.`password`,a.number,a.email,a.linkman,a.linknum,a.address,a.introduce,a.state,a.SHtime,a.SHuser, "
            + "  b.manage,c.type,d.nature,e.industry,f.grading  "
            + "  FROM regist a "
            + "  JOIN manage_unit b on a.manage=b.id"
            + "  JOIN unit_type c on a.type=c.id"
            + "  JOIN unit_nature d on a.nature=d.id"
            + "  JOIN industry e ON a.industry=e.id"
            + "  JOIN grading f on a.grading=f.id"
            +  "  where a.id=#{id}")
    Map chakan(Integer id);


    @Update("update regist  set state=1,SHtime=#{SHtime},SHuser=#{SHuser}  where id=#{id}")
    void shenhe(Map map);

    @Update("update regist  set state=2,SHtime=#{SHtime},SHuser=#{SHuser}  where id=#{id}")
    void shenhe1(Map map);


    @Select(" SELECT  b.manage,a.`name`,c.type,d.nature,e.industry,f.grading,a.unituser,a.number,a.email,a.linkman,a.linknum,a.address,a.introduce"
            + "     FROM regist a  "
            + "  JOIN manage_unit b on a.manage=b.id"
            + "  JOIN unit_type c on a.type=c.id"
            + "  JOIN unit_nature d on a.nature=d.id"
            + "  JOIN industry e ON a.industry=e.id"
            + "  JOIN grading f on a.grading=f.id"
            +  "  where a.name=#{name}")
    Map Ess(String name);

    @Select("select name from regist")
    List<Map> getname();

    @Select(" select state from regist where name=#{name}")
    int getstate(Map map);
}